home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 3006 / 3006.xpi / chrome / dwhelper.jar / content / sites.xul < prev    next >
Extensible Markup Language  |  2010-01-15  |  12KB  |  375 lines

  1. <?xml version="1.0"?> 
  2. <!-- *****************************************************************************
  3.  *            Copyright (c) 2006-2009 Michel Gutierrez. All Rights Reserved.
  4.  ****************************************************************************** -->
  5. <?xml-stylesheet href="chrome://global/skin/" type="text/css"?> 
  6. <?xml-stylesheet href="chrome://dwhelper/skin/dwhelper.css" type="text/css"?>
  7. <?xml-stylesheet href="chrome://dwhelper/content/bindings.css" type="text/css"?>
  8.  
  9. <!DOCTYPE window SYSTEM "chrome://dwhelper/locale/dwhelper.dtd" >
  10.  
  11. <window id="dwhelper-sites"
  12.         title="&version.name;"
  13.         flex="1"
  14.         onload="onLoad()"
  15.         onunload="onUnload()"
  16.         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
  17.         xmlns:html="http://www.w3.org/1999/xhtml"
  18.         screenX="0"
  19.         screenY="0"
  20.         persist="width height screenX screenY sizemode"
  21.         >
  22.  
  23.     <script type="application/x-javascript"
  24.         src="chrome://dwhelper/content/dwhutil.js" />
  25.  
  26.     <script><![CDATA[
  27.  
  28. var Util=Components.classes["@downloadhelper.net/util-service;1"]
  29.     .getService(Components.interfaces.dhIUtilService);
  30. var pref=Components.classes["@mozilla.org/preferences-service;1"]
  31.     .getService(Components.interfaces.nsIPrefService).getBranch("dwhelper.");
  32.  
  33. var datasource=null;
  34.  
  35. var pb2=pref.QueryInterface(Components.interfaces.nsIPrefBranch2);
  36. var observer={
  37.     observe: function(subject,topic,data) {
  38.         if(topic=="nsPref:changed" && (data=="adult" || data=="safe-mode"))
  39.             adultCheck();
  40.     }
  41. }
  42. pb2.addObserver("", observer, false);
  43.  
  44. function onUnload() {
  45.     pb2.removeObserver("",observer);
  46. }
  47.  
  48. function reportSite() {
  49.     var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService().
  50.         QueryInterface(Components.interfaces.nsIWindowWatcher);
  51.     var w=wwatch.openWindow(window, "chrome://dwhelper/content/report.xul",
  52.                  "dwhelper-report-site", "chrome", {});
  53.     setTimeout(new Function("w","w.focus()"),0,w);
  54. }
  55.  
  56. function getSelected() {
  57.     var t=document.getElementById("dwhelper-media-sites");
  58.     var selectCount = t.view.selection.count;
  59.     if(selectCount>0) {
  60.         var res=t.builderView.getResourceAtIndex(t.currentIndex);
  61.         return res;
  62.     }
  63.     return null;
  64. }
  65.  
  66. function updateOpenButton() {
  67.     var b1=document.getElementById("check-button");
  68.     var b2=document.getElementById("comment-button");
  69.     if(getSelected()==null) {
  70.         b1.setAttribute("hidden","true");
  71.         b2.setAttribute("hidden","true");
  72.     } else {
  73.         b1.setAttribute("hidden","false");
  74.         b2.setAttribute("hidden","false");
  75.     }
  76. }
  77.  
  78. function addComment() {
  79.     
  80.     var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].getService().
  81.         QueryInterface(Components.interfaces.nsIWindowWatcher);
  82.         
  83.     var props=Components.classes["@mozilla.org/properties;1"]
  84.         .createInstance(Components.interfaces.nsIProperties);
  85.  
  86.     var siteres=getSelected();
  87.  
  88.     props.set("datasource",datasource);
  89.     props.set("siteres",siteres);
  90.         
  91.     var w=wwatch.openWindow(window, "chrome://dwhelper/content/comment.xul",
  92.                  "dwhelper-comment", "chrome,minimizable", props);
  93.     setTimeout(new Function("w","w.focus()"),0,w);
  94.     
  95. }
  96.  
  97. function checkSite() {
  98.     var siteres=getSelected();
  99.     var siteId=Util.getPropertyValueRS(datasource,siteres,"http://downloadhelper.net/dwhelper/1.0#id");
  100.  
  101.     var top=DWHUtil.getTopWindow();
  102.     if(top) {
  103.         var browser=top.getBrowser();
  104.         var tab = browser.addTab("http://www.downloadhelper.net/site.php?site="+siteId);
  105.         setTimeout(new Function("b","t","b.selectedTab=t;"),0,browser,tab);
  106.     }
  107. }
  108.  
  109. function onLoad() {
  110.  
  111.     var adult=document.getElementById("adult");
  112.     var allowAdult=pref.getBoolPref("adult");
  113.     adult.checked=allowAdult;
  114.     adultCheck();
  115.  
  116.     updateOpenButton();
  117.     var t=document.getElementById("dwhelper-media-sites");
  118.     datasource=t.database;
  119.     t.addEventListener("select",updateOpenButton,true);
  120.     t.addEventListener("dblclick",checkSite,true);
  121.  
  122.     var x=document.documentElement.getAttribute("screenX");
  123.     var y=document.documentElement.getAttribute("screenY");
  124.     window.moveTo(x,y);
  125.  
  126.     var showRegister=false;
  127.     var ce=false;
  128.     try {
  129.         ce=pref.getBoolPref("conversion-enabled");
  130.     } catch(e) {
  131.     }
  132.     var cf=false;
  133.     try {
  134.         cf=pref.getBoolPref("convert-free");
  135.     } catch(e) {
  136.     }
  137.     if(ce==true && cf==true)
  138.         showRegister=true;
  139.     var crt=document.getElementById("bc-convert-register");
  140.     crt.setAttribute("collapsed",""+!showRegister);
  141. }
  142.  
  143. function adultCheck() {
  144.     var filter=document.getElementById("adult-filter");
  145.     var conditions=document.getElementById("conditions");
  146.     var allowAdult=pref.getBoolPref("adult");
  147.     var safeMode=false;
  148.     try {
  149.         safeMode=pref.getBoolPref("safe-mode");
  150.     } catch(e) {}
  151.     document.getElementById("adult").setAttribute("hidden",""+safeMode);
  152.     if(safeMode) {
  153.         allowAdult=false;
  154.     }
  155.     if(allowAdult==true) {
  156.         if(filter!=null) {
  157.             filter.parentNode.removeChild(filter);
  158.             document.getElementById("dwhelper-media-sites").builder.rebuild();
  159.         }
  160.     } else {
  161.         if(filter==null) {
  162.             filter=document.createElement("triple");
  163.             filter.setAttribute("id","adult-filter");
  164.             filter.setAttribute("subject","?site");
  165.             filter.setAttribute("predicate","http://downloadhelper.net/dwhelper/1.0#adult");
  166.             filter.setAttribute("object","0");
  167.             conditions.appendChild(filter);
  168.             document.getElementById("dwhelper-media-sites").builder.rebuild();
  169.         }
  170.     }
  171. }
  172.  
  173. function adultCheckCommand() {
  174.     var button=document.getElementById("adult");
  175.     if(button.checked) {
  176.         var o18checked=false;
  177.         try {
  178.             o18checked=pref.getBoolPref("checked-adult");
  179.         } catch(e) {
  180.         }
  181.         if(o18checked==false) {
  182.             if(confirm(Util.getText("message.show-adult"))==false || 
  183.                 confirm(Util.getText("message.checked-adult"))==false) {
  184.                 button.checked=false;
  185.                 return;
  186.             }
  187.             pref.setBoolPref("checked-adult",true);
  188.         }
  189.     }
  190.     pref.setBoolPref("adult",button.checked);
  191. }
  192.  
  193. ]]>
  194.     </script>
  195.  
  196.     <broadcasters>
  197.         <broadcaster id="bc-convert-register" collapsed="true"/>
  198.     </broadcasters>
  199.     
  200.     
  201.     <tabbox id="dwhelper-sites-tabbox" flex="1">
  202.         <tabs>
  203.             <tab class="dwhelper-tab" label="&title.sites;"/>
  204.             <tab observes="bc-convert-register" class="dwhelper-tab" label="&title.convert-register;" image="chrome://dwhelper/skin/converter-16x16.png"/>
  205.         </tabs>
  206.         <tabpanels flex="1">
  207.             <tabpanel>
  208.  
  209.                 <vbox id="dwhelper-sites-vbox" flex="1">
  210.             
  211.                     <tree id="dwhelper-media-sites"
  212.                         enableColumnDrag="true" 
  213.                         datasources="http://www.downloadhelper.net/sites.rdf"
  214.                         ref="urn:root"
  215.                         flags="dont-build-content"
  216.                         flex="1"
  217.                         >
  218.                         <treecols>
  219.                             <treecol 
  220.                                 id="name"
  221.                                 primary="true"
  222.                                 label="&column.sites.name;"
  223.                                 flex="1"
  224.                                 persist="width ordinal hidden sortActive sortDirection"
  225.                                 sort="?name"
  226.                                 />
  227.                             <splitter class="tree-splitter"/>
  228.                             <treecol 
  229.                                 id="duration"
  230.                                 primary="false"
  231.                                 label="&column.sites.duration;"
  232.                                 flex="1"
  233.                                 persist="width ordinal hidden sortActive sortDirection"
  234.                                 sortActive="true" sortDirection="descending" 
  235.                                 sort="?durationsort"
  236.                                 />
  237.                             <splitter class="tree-splitter"/>
  238.                             <treecol 
  239.                                 id="rating"
  240.                                 primary="false"
  241.                                 label="&column.sites.rating;"
  242.                                 flex="1"
  243.                                 persist="width ordinal hidden sortActive sortDirection"
  244.                                 sortActive="true" sortDirection="descending" 
  245.                                 sort="?ratingsort"
  246.                                 />
  247.                             <splitter class="tree-splitter"/>
  248.                             <treecol 
  249.                                 id="count"
  250.                                 primary="false"
  251.                                 label="&column.sites.count;"
  252.                                 flex="1"
  253.                                 persist="width ordinal hidden"
  254.                                 sort="?count"
  255.                                 />
  256.                             <splitter class="tree-splitter"/>
  257.                             <treecol 
  258.                                 id="date"
  259.                                 primary="false"
  260.                                 label="&column.sites.date;"
  261.                                 flex="1"
  262.                                 persist="width ordinal hidden"
  263.                                 sort="?timestamp"
  264.                                 />
  265.                             <splitter class="tree-splitter"/>
  266.                             <treecol 
  267.                                 id="url"
  268.                                 hidden="true"
  269.                                 primary="false"
  270.                                 label="&column.sites.url;"
  271.                                 flex="1"
  272.                                 persist="width ordinal hidden"
  273.                                 sort="?url"
  274.                                 />
  275.                         </treecols>
  276.                 
  277.                         <template>
  278.                             <rule>
  279.                                 <conditions id="conditions">
  280.                                     <content uri="?root"/>
  281.                                     <member container="?root" child="?site"/>
  282.                                     <triple id="adult-filter" subject="?site"
  283.                                          predicate="http://downloadhelper.net/dwhelper/1.0#adult"
  284.                                          object="0"/>
  285.                                 </conditions>
  286.                                 <bindings>
  287.                                     <binding subject="?site"
  288.                                          predicate="http://downloadhelper.net/dwhelper/1.0#name"
  289.                                          object="?name"/>
  290.                                     <binding subject="?site"
  291.                                          predicate="http://downloadhelper.net/dwhelper/1.0#duration"
  292.                                          object="?duration"/>
  293.                                     <binding subject="?site"
  294.                                          predicate="http://downloadhelper.net/dwhelper/1.0#durationsort"
  295.                                          object="?durationsort"/>
  296.                                     <binding subject="?site"
  297.                                          predicate="http://downloadhelper.net/dwhelper/1.0#rating"
  298.                                          object="?rating"/>
  299.                                     <binding subject="?site"
  300.                                          predicate="http://downloadhelper.net/dwhelper/1.0#ratingsort"
  301.                                          object="?ratingsort"/>
  302.                                     <binding subject="?site"
  303.                                          predicate="http://downloadhelper.net/dwhelper/1.0#timestamp"
  304.                                          object="?timestamp"/>
  305.                                     <binding subject="?site"
  306.                                          predicate="http://downloadhelper.net/dwhelper/1.0#date"
  307.                                          object="?date"/>
  308.                                     <binding subject="?site"
  309.                                          predicate="http://downloadhelper.net/dwhelper/1.0#count"
  310.                                          object="?count"/>
  311.                                     <binding subject="?site"
  312.                                          predicate="http://downloadhelper.net/dwhelper/1.0#url"
  313.                                          object="?url"/>
  314.                                     <binding subject="?site"
  315.                                          predicate="http://downloadhelper.net/dwhelper/1.0#type"
  316.                                          object="?type"/>
  317.                                   </bindings>
  318.                                   <action>
  319.                                     <treechildren>
  320.                                         <treeitem
  321.                                             uri="?site" open="true">
  322.                                             <treerow>
  323.                                                 <treecell                
  324.                                                     label="?name"
  325.                                                     properties="?type"
  326.                                                     />
  327.                                                 <treecell                
  328.                                                     label="?duration"
  329.                                                     />
  330.                                                 <treecell                
  331.                                                     label="?rating"
  332.                                                     />
  333.                                                 <treecell                
  334.                                                     label="?count"
  335.                                                     />
  336.                                                 <treecell                
  337.                                                     label="?date"
  338.                                                     />
  339.                                                 <treecell                
  340.                                                     label="?url"
  341.                                                     />
  342.                                             </treerow>
  343.                                         </treeitem>
  344.                                     </treechildren>
  345.                                 </action>
  346.                             </rule>
  347.                         </template>
  348.                 
  349.                     </tree>
  350.                     
  351.                     <checkbox id="adult" label="&label.sites.list-adult;" oncommand="adultCheckCommand()" hidden="true"/>
  352.                     
  353.                     <hbox class="dwhelper-button-line">
  354.                         <spacer flex="1"/>
  355.             <!-- 
  356.                         <button label="&button.sites.report;" oncommand="reportSite()"/>
  357.              -->
  358.                         <button id="check-button" label="&button.site.check;" oncommand="checkSite()" hidden="true"/>
  359.                         <button id="comment-button" label="&button.site.comment;" oncommand="addComment()" hidden="true" />
  360.             <!-- 
  361.                         <button id="open-button" label="&button.sites.open;" hidden="true" oncommand="doOpen()"/>
  362.              -->
  363.                         <button label="&button.sites.close;" oncommand="window.close()"/>
  364.                     </hbox>
  365.             
  366.                 </vbox>
  367.             </tabpanel>
  368.             <tabpanel observes="bc-convert-register" >
  369.                 <ConvertRegister autovisit="true"/>
  370.             </tabpanel>
  371.         </tabpanels>
  372.     </tabbox>
  373.     
  374. </window>
  375.